# -*- coding: utf-8 -*-
"""
@Env 
@Time 2024/9/3 上午10:26
@Author yzpang
@Function: FAST API应用构建
"""
from fastapi import FastAPI
from fastapi.responses import Response

from .controller import model_controller, train_controller, evaluate_controller, inference_controller, data_controller


def create_app():
    """
    创建fastapi应用app
    :return: app
    """
    app = FastAPI()

    # 挂载路由
    mount_app_routes(app)

    return app


def mount_app_routes(app):
    """
    路由挂载方法
    :param app:
    """
    @app.get('/index')
    def index():
        return Response(content='Fast Api Started Successfully', status_code=200)

    # 挂载模型接口
    model_controller.mount_model_routes(app)
    # 挂载训练接口
    train_controller.mount_train_routes(app)
    # 挂载评估接口
    evaluate_controller.mount_evaluate_routes(app)
    # 挂载推理接口
    inference_controller.mount_inference_routes(app)
    # 挂载数据集处理接口
    data_controller.mount_data_routes(app)


